package edu.etu.sob.service;

import java.util.HashMap;

import virtuoso.jena.driver.VirtGraph;

public class GraphProvider {
	
	private static GraphProvider instance = null;
	private HashMap<String, VirtGraph> graphCache = new HashMap<String, VirtGraph>();
	
	private GraphProvider() {
		
	}
	
	public static GraphProvider getInstance() {
		if (instance == null)
			instance = new GraphProvider();
		return instance;
	}
	
	public void cacheGraph(String graphKey, final VirtGraph graph) {
		graphCache.put(graphKey, graph);
	}
	
	public VirtGraph getGraph(String key) {
		return isGraphAvailable(key) ? graphCache.get(key) : null;
	}
	
	public boolean isGraphAvailable(String key) {
		return graphCache.containsKey(key);
	}
	
}
